package com.ygp.cas;

import java.util.ArrayList;
import java.util.List;

/**
 * <Description> <br>
 *
 * @author linmiaolai@sanyygp.com<br>
 * @version 1.0<br>
 * @date 2021/08/30 <br>
 */
public class CasTest {
    public static void main(String[] args) throws InterruptedException {
        new CasTest().unSafeTest();
    }

    public void unSafeTest() throws InterruptedException {
        MyAtomicInteger myAtomicInteger = new MyAtomicInteger();
        List<Thread> ts = new ArrayList<Thread>(600);
        for (int j = 0; j < 10; j++) {
            /*Thread t = new Thread(() -> {
                for (int i = 0; i < 10000; i++) {
                    myAtomicInteger.getAndIncrement();
                }
            });*/
//            ts.add(t);
        }
        for (Thread t : ts) {
            t.start();
        }
        for (Thread t : ts) {
            t.join();
        }
        System.out.println(myAtomicInteger.getValue());
    }
}
